#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10,M=1e6+10;
long long n,m,L,V;
long long d[N],vot[N];
struct Node{
    int x,v,a;

}c[N],tc[N];
int cnt=0;
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
	
    while(T--)
    {
        cin>>m>>n>>L>>V;
        L+=1;
        cnt=0;
        for(int i=1;i<=m;i++)
        {
            int a1,b1,c1;
            cin>>a1>>b1>>c1;
            a1+=1;
            if(b1<=V&&c1<=0)continue;
            if(b1<=V&&b1*b1+2*c1*(L-a1)<=V*V)continue;
            c[++cnt]={a1,b1,c1};
        }
        for(int i=1;i<=n;i++)
        {
            cin>>d[i];
            d[i]+=1;
        }
        m=cnt;
        cnt=0;
        int ans=0;
        for(int i=1;i<=m;i++)
        {
            bool t=true;
            for(int j=1;j<=n;j++)
            {
                if(d[j]<c[i].x)continue;
                if(c[i].v*c[i].v+2*c[i].a*(d[j]-c[i].x)<=V*V)continue;
                vot[j]++;
                t=false;
            }
            if(!t)
            {
                ans++;
                tc[++cnt]=c[i];
            }
        }
        cout<<ans<<" ";
        int tt=0;
        while(cnt!=0)
        {
            m=cnt;
            for(int i=1;i<=m;i++)
                c[i]=tc[i];
            cnt=0;
            int ma=0,mai=0;
            for(int i=1;i<=n;i++)
            {
                if(vot[i]>ma)ma=vot[i],mai=i;
            }
            memset(vot,0,sizeof vot);
            for(int i=1;i<=m;i++)
            {
                bool t=true;
                for(int j=1;j<=n;j++)
                {
                    if(d[j]<c[i].x)continue;
                    if(d[mai]>=c[i].x&&c[i].v*c[i].v+2*c[i].a*(d[mai]-c[i].x)>V*V)break;
                    if(c[i].v*c[i].v+2*c[i].a*(d[j]-c[i].x)<=V*V)continue;
                    vot[j]++;
                    t=false;
                }
                if(!t)
                {
                    tc[++cnt]=c[i];
                }
            }
            tt++;
        }
        cout<<n-tt<<endl;
    }
    return 0;
}
